<template>
  <div id="saleset">  
    <div  style="display:flex;align-items: center;">
            <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
            <div style="line-height: 40px;font-weight:bold:">挂卖设置</div>
     </div> 
    <el-form ref="form"  label-width="0px">  
     <el-row> 
             <el-col :span="24" style="text-align: right;">   
                <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="add_but()">
                  <img class="custom_color_button1_img" src="@/assets/images/but_bg2.png" />添加
                </el-button>         
             </el-col>  
    </el-row>
   </el-form>
   <!-- 渲染数据list -->
   <sale-set-list :datalist="datalist" @up_list_fun="list_fun"> </sale-set-list>

      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>

       <!-- 添加 -->
        <el-dialog title="添加" :visible.sync="mtk"  width="350px">
            <div style="width:100%;"> 

            <el-form ref="form"   label-width="0px" style="width:100%;"> 
                 <el-form-item label="" label-width="0px" >
                    <el-input v-model="mtk_form.telphone" placeholder="请输入手机号"></el-input>
                </el-form-item> 
            </el-form>
            <div style="text-align: center;width:50%;margin:auto;margin-top:20px;">
                <el-button type="primary" class="custom_color_button" style="width:100%;" @click="qr_but">确认</el-button>
            </div>
            </div> 
        </el-dialog>

    

      
  </div>
</template>

<script>
import SaleSetList from '@/view/Manor/SaleSetList'
export default {
  name: 'saleset',
  data () {
    return {
        datalist:[],
        page:1,
        count:0,
        mtk:false,
        mtk_form:{
          telphone:'',
        },
    }
  },
 components:{
    SaleSetList
  },
  created(){ 

    this.list_fun()
  },
  mounted (){

  },
  methods: {
      list_fun(){
         this.post("/onsale_privilege/listOfData", {
              page:this.page,
	        }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list
            console.log(res,"aaa")
         })
      },
      add_but(){
          this.mtk = true
          this.mtk_form.telphone = ''
      },
      qr_but(){
          this.post("/onsale_privilege/add", {
               telphone:this.mtk_form.telphone
            }).then(res => {

                if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.list_fun()
                    this.mtk = false
                }else {
                this.open1(res.message,'warning')
            }

        })
      },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>

</style>
